<template>
  <div class="steps">
    <div :class="{ 'step-box': true, active: item.isActive }" v-for="(item, index) in stepsData" :key="index">
      <div class="step-icon-text">
        <img :src="item.isActive ? item.imageY : item.imageB" width="30" alt="" />
        <span class="title">{{ item.title }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    stepNum: {
      type: Object,
      default: { index: undefined, flag: undefined }
    },
    allStepActive: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    stepNum: {
      handler(val) {
        console.log(val);
        if (val.index != undefined) this.stepsData[val.index].isActive = val.flag
      }
    },
    allStepActive: {
      handler(val) {
        console.log(val);
        this.stepsData.map(item => {
          item.isActive = val
        })
      }
    }
  },
  data() {
    return {
      stepsData: [
        {
          imageB: require('@/assets/bmsjkhsp/1-b.png'),
          imageY: require('@/assets/bmsjkhsp/1-y.png'),
          title: '选择审计资产',
          isActive: false
        },
        {
          imageB: require('@/assets/bmsjkhsp/2-b.png'),
          imageY: require('@/assets/bmsjkhsp/2-y.png'),
          title: '定制指标参数',
          isActive: false
        },
        {
          imageB: require('@/assets/bmsjkhsp/3-b.png'),
          imageY: require('@/assets/bmsjkhsp/3-y.png'),
          title: '定制输出指标',
          isActive: false
        },
        {
          imageB: require('@/assets/bmsjkhsp/4-b.png'),
          imageY: require('@/assets/bmsjkhsp/4-y.png'),
          title: '完成配置',
          isActive: false
        },
        {
          imageB: require('@/assets/bmsjkhsp/5-b.png'),
          imageY: require('@/assets/bmsjkhsp/5-y.png'),
          title: '执行结果',
          isActive: false
        }
      ]
    }
  }
}
</script>

<style lang="less" scoped>
.steps {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;

  .step-box {
    display: flex;
    align-items: center;
    width: 23%;
    .step-icon-text {
      width: 25%;
      display: flex;
      flex-direction: column;
      gap: 2px;
      align-items: center;
      .title {
        font-size: 14px;
        color: #111;
      }
    }
  }
  .step-box:nth-of-type(1) {
    width: 8%;
    .step-icon-text {
      width: 100%;
    }
  }
  .step-box:nth-of-type(1)::before {
    display: none;
  }
  .step-box::before {
    content: '';
    display: block;
    width: 75%;
    height: 7px;
    background-color: #dfe5f9;
    border-radius: 5px;
  }
  .active::before {
    background-color: #f3943e;
  }
  .active {
    .step-icon-text {
      .title {
        color: #f3943e;
      }
    }
  }
}
</style>
